using System;
using System.Data;
using System.Collections.Generic;
using System.Text;


namespace THSLib
{
    public class STModulesController:BaseBusinessController
    {

        public STModulesController()
        {
            //dal = new STModulesDAL();
            dal = new DALBaseProvider("STModules", typeof(STModulesInfo));
        }              

        public bool IsMainModule(String strModuleName)
        {
            bool isMainModule=true;
            STModulesInfo objSTModulesInfo = (STModulesInfo)GetObjectByName(strModuleName);
            if (objSTModulesInfo != null)
            {
                if (objSTModulesInfo.STModuleMain == 0)
                    isMainModule = false;
            }            
            return isMainModule;
        }

        public override DataSet GetAllObjects()
        {
            String query = String.Format("SELECT * FROM STModules WHERE AAStatus = 'Alive'");
            DataSet ds = GetDataSet(query);
            
            DataColumn column = new DataColumn("STModuleDescription", typeof(String));
            ds.Tables[0].Columns.Add(column);
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                STModulesController objModulesController = new STModulesController();
                STModulesInfo objModulesInfo = (STModulesInfo)objModulesController.GetObjectFromDataRow(row);
                STModuleDescriptionsController objModuleDescriptionsController = new STModuleDescriptionsController();
                STModuleDescriptionsInfo objModuleDescriptionsInfo = (STModuleDescriptionsInfo)objModuleDescriptionsController.GetObjectByModuleID(objModulesInfo.STModuleID);
                row["STModuleDescription"] = objModuleDescriptionsInfo.STModuleDescriptionDescription;
            }
            return ds;
        }

    }
}
